from toscawidgets.widgets.forms import CheckBox, TextField, SingleSelectField, \
                                       validators
from widgets import *

__all__ = ["SampleGrid", "SampleGridWithWidgets", "SampleEditableGrid"]

class Person:
    def __init__(self, name, age, enabled=False):
        self.__dict__.update(locals())

class SampleGrid(Grid):
    columns = ["name", "age", "enabled"]
    default = [
        Person("Peter", 85, True),
        Person("Sue", 32),
        Person("Candy", 23, True),
        Person("Gregor", 12),
        Person("Beth", 40),
        ]


class SampleGridWithWidgets(Grid):
    columns = ["name", "age", CheckBox('enabled')]
    default = [
        Person("Peter", 85, True),
        Person("Sue", 32),
        Person("Candy", 23, True),
        Person("Gregor", 12),
        Person("Beth", 40),
        ]


class SampleEditableGrid(EditableGrid):
    columns = [
        TextField('name'), 
        SingleSelectField("age", validator=validators.Int, options=range(100)), 
        CheckBox('enabled'),
        ]
    default = [
        Person("Peter", 85, True),
        Person("Sue", 32),
        Person("Candy", 23, True),
        Person("Gregor", 12),
        Person("Beth", 40),
        ]

